package com.itheima.springbootmybatis.service.impl;

import com.itheima.springbootmybatis.dao.UserMapper;
import com.itheima.springbootmybatis.domain.User;
import com.itheima.springbootmybatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:
 * @Version: V1.0
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    /**
     * 查询所有
     * @return
     */
    public List<User> findAll() {
        return userMapper.findAll();
    }

    /**
     * 更新操作
     * @param user
     */
    public void update(User user) {
        userMapper.update(user);
    }

    /**
     * 根据id 查询
     * @param id
     * @return
     */
    public User findById(Integer id){
        return userMapper.findById(id);
    }

    /**
     * 删除操作
     * @param id
     */
    public void delete(Integer id) {
        userMapper.delete(id);
    }

    /**
     * 添加操作
     * @param user
     */
    public void insert(User user) {
        userMapper.insert(user);
    }
}
